﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;

namespace FancyIdea.PingShui.Core.Dal
{
    public class 评税从业人员操作
    {
        public static bool AddEmployees(DataTable table)
        {
            if (table == null || table.Rows.Count < 1) return false;
            string sql = @"insert into 评税从业人员表 (评税信息ID,从业人员ID,从业人员人数,从业人员平均工资) 
values (@PID,@CID,@count,@money)";
            using (OracleCmd cmd = new OracleCmd())
            {
                cmd.BeginTransaction();
                cmd.SetCommand(sql);
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    cmd.AddParameter("@PID", table.Rows[i][0].ToString())
                        .AddParameter("@CID", table.Rows[i][1].ToString())
                        .AddParameter("@count",table.Rows[i][2].ToString())
                        .AddParameter("@money",table.Rows[i][3].ToString());
                    if (cmd.ExecuteNonQuery() < 1)
                    {
                        cmd.RollbackTransaction();
                        return false;
                    }
                    cmd.ClearParameters();
                }
                cmd.CommitTransaction();
                return true;
            }
        }

        public static DataTable GetEmployees(int 评税信息ID)
        {
            string sql = @"select 从业人员ID,从业人员人数,从业人员平均工资 from 评税从业人员表 
where 评税信息ID=" + 评税信息ID;
            return CmdUtil.ExcuteDataTable(sql);
        }
    }
}